﻿<?php //Seyret Component v.0.3//
/**
* @package Seyret
* @version 0.3
* @copyright Copyright (C) 2008 Mustafa DINDAR. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Seyret Video Component is a free software.
* See seyrettos.html for license notices and details.
*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );



echo $this->toolbar;
echo $this->modtoolbar;


$document = & JFactory::getDocument();



$jslink=JURI :: root()."components/com_seyret/includes/js/jquery-ui-1.7.2.custom.min.js";
$document->addScript($jslink);


$user =& JFactory::getUser();
?>

<script type="text/javascript">

var selectedthumbnail = 1;

jQuery(document).ready(function(){
	var list = jQuery('#myQuickList').sortable({ 
		opacity: 0.6,
		revert: true,		
		helper: 'original',
		axis: 'y',
		cursor: 'move',
		items: 'li',
		update: function(event, ui) { 
			var  neworder= jQuery(this).sortable('toArray');
			var neworderstr = "";
			jQuery(neworder).each(function(index, item){
				neworderstr = neworderstr + item;
			});

			var quicklistcounter = 0;
			var oddeven;
			var remoddeven;
			jQuery('div.quicklistrownumber').each(function(div) {
				quicklistcounter = quicklistcounter + 1;
				if (quicklistcounter % 2 == 0) {
					oddeven = 1; 
					remoddeven = 0;
				} else {
					oddeven = 0;
					remoddeven = 1;
				}
				 
				jQuery(this).text(quicklistcounter);
			
			
				});
				
				jQuery.cookie('seyretql', neworderstr, {path: '/'});
			}
		
		});
		
	
});


function changethumbnail() {
	selectedthumbnail = selectedthumbnail + 1;
	if (selectedthumbnail > <?php echo count($this->quicklistdata); ?>) selectedthumbnail = 1;
	var thumbid = 'thumb' + selectedthumbnail;
	var newthumb = jQuery('#' + thumbid).attr('src');
	jQuery('#playlistselthumb').attr('src', newthumb);
	jQuery('#playlistthumbnail').attr('value', newthumb);
}


function validate_form(thisform)
{
	with (thisform)
	{
		 
		if ($("playlisttitle").value=="") {
			$("playlisttitle").removeClass('seyretinputbox').addClass('redseyretinputbox');
			var returnvalue="false";
		} else {
			$("playlisttitle").removeClass('redseyretinputbox').addClass('seyretinputbox');
		}
		
		if ($("playlistthumbnail").value=="") {
			$("playlistthumbnail").removeClass('seyretinputbox').addClass('redseyretinputbox');
			var returnvalue="false";
		} else {
			$("playlistthumbnail").removeClass('redseyretinputbox').addClass('seyretinputbox');
		}
		
	}
	
	
	if (returnvalue=="false") {
		return false;
	}
}

</script>


<form id="qlform" name="qlform" action="index.php?option=com_seyret&amp;view=user&amp;task=savequicklist" method="post" onsubmit="return validate_form(this)">
	
	

	<div class="editquicklistinfo">
		<p><?php echo JText::_('Please fill required fields to save your quick list');?></p>
		<p><?php echo JText::_('You can arrange the order of your list by dragging videos');?></p>
	</div>


	<div>
	<div class="editquicklistinputform">
		
		<div style="margin:auto; text-align:center;">
			<img id="playlistselthumb" class="playlistselthumb" alt="" src="<?php echo htmlentities($this->quicklistdata[0]->videothumbnail); ?>"/>&nbsp;
			<img class="playlistselthumbchanger" alt="" src="<?php echo JURI::root()."components/com_seyret/themes/default/images/change_qlthumb.png";?>" onclick="changethumbnail()"/>
		</div>
		
		<div class="seyretquicklisteditformlabel"><?php echo JText::_('Playlist Thumbnail');?></div>
		<div class="seyretquicklisteditforminput"><input type="text" name="playlistthumbnail" id="playlistthumbnail" class="editvideoinputbox seyretinputbox" value="<?php echo htmlentities($this->quicklistdata[0]->videothumbnail) ; ?>" /></div>	
		<div class="clear"></div>
		
		<div class="seyretquicklisteditformlabel"><?php echo JText::_('Playlist Title');?></div>
		<div class="seyretquicklisteditforminput"><input type="text" name="playlisttitle" id="playlisttitle" class="editvideoinputbox seyretinputbox" value="" /></div>	
		<div class="clear"></div>

		<div class="seyretquicklisteditformlabel"><?php echo JText::_('Playlist Description');?></div>
		<div class="seyretquicklisteditforminput"><input type="text" name="playlistdescription" id="playlistdescription" class="editvideoinputbox seyretinputbox" value="" /></div>	
		<div class="clear"></div>

		
		<div class="seyretquicklisteditformlabel"><?php echo JText::_('Playlist Tags');?></div>
		<div class="seyretquicklisteditforminput"><input type="text" name="playlisttags" id="playlisttags" class="editvideoinputbox seyretinputbox" value="" /></div>	
		<div class="clear"></div>

		<div class="seyretquicklisteditformlabel"><?php echo JText::_('Open to public');?></div>
		<div class="seyretquicklisteditforminput"><?php echo $this->opentopublicselect; ?></div>
			
		<div class="clear"></div>
		<input type="submit" value="<?php echo JText::_('Save');?>" id="submit" class="seyretbuttonnarrow" />	
	</div>

	

			
	
	
			
	<div id="quicklistsortdiv" style="position:relative; float:right;" >
		<ul id="myQuickList">
	<?php 
		$counter=0;
		foreach ($this->quicklistdata as $quicklistdata) {
		$counter++;
		?>
		
		<li id="a<?php echo $quicklistdata->id;?>a" class="quicklistsort<?php echo ($counter % 2) ? '0' : '1'; ?>">
			<div class="quicklistrownumber"><?php echo $counter;?></div>
			<div style="float:left;"><img id="thumb<?php echo $counter;?>" class="quicklisteditpagethumb" src="<?php echo htmlentities($quicklistdata->videothumbnail);  ?>" alt=""/></div>
			<div class="quicklistsortvideotitle"><?php echo $quicklistdata->videotitle; ?></div>
			<div class="clear"></div>
		
		</li>

		<?php
		}

	?>
		</ul>	
	</div>

	</div>

</form>	

